package com.hjl.service.bill;

import com.hjl.dao.bill.BillMapper;
import com.hjl.entity.Bill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("billService")
public class BillServiceImpl implements BillService {

    @Autowired
    private BillMapper billMapper;

    @Override
    public List<Bill> selectListInfos(String productName, Integer id, Integer isPayment) {

        try {
            return billMapper.selectListInfos(productName,id,isPayment);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public boolean addInfo(Bill bill) {

        boolean flag = false;
        try {
            if (billMapper.addBillInfos(bill) > 1) {
                flag = true;
            }
            return flag;
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int updateInfo(Bill bill) {

        try {
            int result = billMapper.updateBillInfos(bill);
            return result;
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int deleteInfo(Integer id) {

        try {
            int result = billMapper.deleteBillInfo(id);
            return  result;
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }
/*
    public BillMapper getBillMapper() {
        return billMapper;
    }

    public void setBillMapper(BillMapper billMapper) {
        this.billMapper = billMapper;
    }*/
}
